package com.tubi.Duration;

import java.time.Duration;
import java.time.LocalDateTime;

public class Duration1 {
    public static void main(String[] args) {

        //| 方法名                                           | 说明                 |
        LocalDateTime of = LocalDateTime.of(2021, 1, 1, 1, 1);
        LocalDateTime now = LocalDateTime.now();
        //| public static Durationbetween(开始时间,结束时间) | 计算两个“时间"的间隔 |
        Duration bet = Duration.between(of, now);
        System.out.println(bet); //PT115H23M57.928S
        //| public long toSeconds()                          | 获得此时间间隔的秒   |
//        System.out.println(bet.toSeconds()); //报错
        //| public int toMillis()                            | 获得此时间间隔的毫秒 |
        System.out.println(bet.toMillis());
        //| public int toNanos()                             | 获得此时间间隔的纳秒 |
        System.out.println(bet.toNanos());
    }
}
